﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using AmiangDAL;
using AmiangBLL;
using AmiangDTO;
namespace AmiangProject
{
    public partial class ucBienDongGiaCa : DevExpress.XtraEditors.XtraUserControl
    {
        bllBienDongGiaCa bll = new bllBienDongGiaCa();
        static BanHang2DataContext dbs = new BanHang2DataContext();
        public ucBienDongGiaCa()
        {
            InitializeComponent();
        }

        private void ucBienDongGiaCa_Load(object sender, EventArgs e)
        {
            DataTable da = new DataTable();
            da = bll.GetDataTableNormally();
            dgvBienDongGiaCa.DataSource = da;
        }

        private void btnTim_Click(object sender, EventArgs e)
        {
            DataTable da = new DataTable();
            var findData = from n in dbs.BIENDONGGIACAs
                           where n.MaMH.Contains(txtMaMatHang.Text)
                           select n;
            da = bll.GetDataTableCondition(findData);
            dgvBienDongGiaCa.DataSource = da;
        }

        private void txtMaMatHang_KeyPress(object sender, KeyPressEventArgs e)
        {
            if(e.KeyChar==13)
            {
                btnTim_Click(null, null);
            }
        }
    }
}
